package com.example.bmysurprisemeal.controller;

import com.example.bmysurprisemeal.model.Restaurant;
import com.example.bmysurprisemeal.service.RestaurantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/restaurants")
public class RestaurantController {

    @Autowired
    private RestaurantService restaurantService;

    @GetMapping("/example")
    public Restaurant getExampleRestaurant() {
        return new Restaurant("惊喜餐厅", "市中心", "特色美食");
    }

    @PostMapping("/add")
    public Restaurant addRestaurant(@RequestBody Restaurant restaurant) {
        return restaurantService.addRestaurant(restaurant);
    }

    @GetMapping("/search")
    public Restaurant searchRestaurant(@RequestParam String name) {
        return restaurantService.findByName(name);
    }
}